﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;
using MusicExplorer.View.Popup;
using MusicExplorer.ViewModel.Popup;
using MusicExplorer.WebRepository;

namespace MusicExplorer.View
{
    /// <summary>
    /// Logique d'interaction pour WebRepositoryTree.xaml
    /// </summary>
    public partial class WebRepositoryTree : UserControl
    {
        public WebRepositoryTree()
        {
            InitializeComponent();
        }

        private void GroupChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            listWebRepositories.SelectedItem = null;
        }

        private void ListChanged(object sender, MouseButtonEventArgs e)
        {
            TreeViewItem item = treeWebRepositories.SelectedItem as TreeViewItem;
            if (item != null)
            {
                item.IsSelected = false;
            }
            else
            {
                item = treeWebRepositories.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem;
                if (item != null)
                {
                    item.IsSelected = true;
                    item.IsSelected = false;
                }
            }
        }
    }
}
